﻿@using Wheeler.Web.Utility;
@using Wheeler.Common.Extensions;
@using Wheeler.Web.ViewModels;
@using Wheeler.Domain;
@using System.Data;
@{
	String pageTitle = "Admin Dashboard";   
    ViewBag.Title = Html.GetPageTitle(pageTitle);
    ViewData[AppConstants.ViewDataKeys.SELECTED_MENU] = AdminMenu.Dashboard;

    UtilityDAO dao = new UtilityDAO();
    WheelerEntities _Context = new WheelerEntities();
    DataSet _ImportedFiles = dao.GetDataSet("SELECT DISTINCT FileName, ImportedOn FROM FixedVehicle GROUP BY FileName", null, false);
    int _VehicleCount = _Context.Vehicles.Count();
    int _FinalizedTestResultCount = (from P in _Context.TestResults where P.HasConfirmed && P.HasPublished select P).Count();
    int _UnfinaledTestResultCount = (from P in _Context.TestResults where !P.HasConfirmed || !P.HasPublished select P).Count();
    int _TestResultCount = _Context.TestResults.Count();

    int _FixedVehicleCount = _Context.FixedVehicles.Count();
}

<div class="jb-page-heading">
    <h1>@pageTitle</h1>
    <div>
        Manage @ConfigReader.SiteName with total administrative permission.
    </div>
</div>

<div class="jb-page-content">
    <div class="row-fluid">
        <div class="span6">
            <div class="jb-group-title">Auto Rickshaws</div>
            <table class="data-table-list">
                <tr>
                    <td>CNG Auto Rickshaw Registered</td>
                    <td>@(_Context.Vehicles.Count())</td>
                </tr>
            </table>

            <div class="jb-group-title">Summary of Data Sheets</div>
            <table class="data-table-list">
                <tr>
                    <td>Published Data Sheets</td>
                    <td>@_FinalizedTestResultCount</td>
                </tr>
                <tr>
                    <td>Unpublished Data Sheets</td>
                    <td>@_UnfinaledTestResultCount</td>
                </tr>
                <tr>
                    <td>Total Data Sheets</td>
                    <td>@_TestResultCount</td>
                </tr>
            </table>
        </div>
        <div class="span6">
            <div class="jb-group-title">BRTA Auto Rickshaws</div>
            <table class="data-table-list">
                <tbody>
                    <tr>
                        <td>So far Total Imported</td>
                        <td>@_FixedVehicleCount</td>
                    </tr>
                </tbody>
                @if (_ImportedFiles.Tables[0].Rows.Count > 0)
                {
                <tbody>
                    <tr>
                        <th>File Name</th>
                        <th>Imported On</th>
                    </tr>
                    @foreach (DataRow row in _ImportedFiles.Tables[0].Rows)
                    {
                    <tr>
                        <td>@Wheeler.Common.DB.NullHandler.GetString(row["FileName"])</td>
                        <td>@Wheeler.Common.DB.NullHandler.GetDateTime(row["ImportedOn"]).ToString(AppConstants.ValueOf.DATE_FROMAT_DISPLAY_WITH_TIME)</td>
                    </tr>
                    }
                </tbody>
                }
            </table>
        </div>
        <div class="clearfix"></div>

        
    </div>
</div>